#include<stdio.h>
#include<stdlib.h>
#define STACK 100
#define STACKINCRMENT 10
typedef char elemtype;
typedef struct sqstack{
	elemtype *base;
	elemtype *top;
	int stacksize;
}sqstack;

void initstack(sqstack *s)
{
	s->base=(elemtype*)malloc(STACK*sizeof(elemtype));
	s->top=s->base;
	s->stacksize=STACK;
}

void push(sqstack *s,elemtype e)
{
	if(s->top-s->base>=s->stacksize)
	{
		s->base=(elemtype*)realloc(s->base,(s->stacksize+STACKINCRMENT)*sizeof(elemtype));
		s->top=s->base+s->stacksize;
		s->stacksize+=STACKINCRMENT;
	}
	*s->top++=e;
}

elemtype pop(sqstack *s)
{
	elemtype e;
	if(s->top!=s->base)
	{
		e=*--s->top;
		return e;
	}
}

int main()
{
	sqstack s;
	elemtype e,p;
	int flag =0,length=0;
	initstack(&s);
	scanf("%c",&e);
	while(e!='&'&&flag==0)
	{
		push(&s,e);
		length++;
		scanf("%c",&e);
	}
	if(e=='&')
	{
		flag=1;
	}
	if(flag==1)
	{
		scanf("%c",&e);
		while(e!='\n'&&s.top!=s.base)
		{
			p=pop(&s);
			if(e!=p)
			{
				printf("NO\n");
				return 0;
			}
			else
			{
				scanf("%c",&e);
			}
		}
	}
	printf("YES\n");
	return 0;
}

